<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = ["a", "b", "c"];
        console.log(arr);   //  ['a', 'b', 'c']
        console.log(arr[0],arr[1],arr[2]);  // a b c
        // 展开数组
        console.log(...arr);               // a b c

        // var arr1 = [arr[0],arr[1],arr[2]]
        // arr1[0] = "aaa";
        // console.log(arr);    // ['a', 'b', 'c']

        var arr1 = [0, ...arr, "d"];
        arr1[0] = "aaa";
        console.log(arr);  // ['a', 'b', 'c']
        console.log(arr1); //  ['aaa', 'a', 'b', 'c', 'd']
        // arr1[1] = "aaa";
        // console.log(arr1);  //['aaa', 'aaa', 'b', 'c', 'd']
        // 浅复制
        var arr1 = arr;
        arr1[0] = "aaa";
        console.log(arr); // ['aaa', 'b', 'c']

        var obj = {
            name:"lili",
            age:18,
        }
        // 对象的展开
        var obj1 = {
            ...obj,
            phone:37827382
        }
        console.log(obj1);  // {name: 'lili', age: 18, phone: 37827382}

        var a = 10;
        var obj2 = {
            a,   //a:a,   // 属性名:变量名, 当属性名和变量名一样的时候,可以简写一个属性名
            name:"obj2",
            run:function(){
                console.log("run",this); //obj2
            },
            run1(){  //函数的简写
                console.log("run1111",this); //obj2
            },
            age:18,
        }
        console.log(obj2.a); // 10

        obj2.run();   // run {a: 10, name: 'obj2', age: 18, run: ƒ, run1: ƒ}
        obj2.run1();  // run1111 {a: 10, name: 'obj2', age: 18, run: ƒ, run1: ƒ}


        obj = {
            name:"nana"
        };
        console.log(obj.name);      // nana
        console.log(obj["name"]);    // nana

        obj["age"] = 10;
        obj.age = 6;

        for(var k in obj){
            console.log(k); // "name"  "age"
            console.log(obj[k]);  //name 6
        }
        

    </script>
</body>

</html>